<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java"  isELIgnored="false"  contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/header.jsp"%>
<html>

<head>
<title><s:i18n name="menus"><s:text name="sameChannel"></s:text></s:i18n></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="apple-mobile-web-app-capable" content="yes" />

 <script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
 <%-- <script type="text/javascript" src="${pageContext.request.contextPath}/fare/js/show.js"></script>--%>
<%--  <link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" /> --%>

<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src="<%=request.getContextPath() %>/FusionCharts/FusionCharts.js"></script>
<script src="<%=request.getContextPath() %>/fare/js/loadPlaneNo.js" type="text/javascript"></script>
</head>
<%-- <script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script> --%>

<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">

<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/jsFile/wait/js/wait.js"></script>	
<script type="text/javascript">
$(function(){
	
if($("#depCity").val()=="") {
	$("#depCity").val("请选择");
	$("#arrCity").val("请选择");
		
	}
$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,changeDoFusion: changeEvent});
$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,changeDoFusion: changeEvent});
if($('#depTime').val()==''){
	$('#depTime').val(currentDate());
}
var d=["<s:i18n name='forms'><s:text name='forms.Sunday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Monday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Tuesday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Wednesday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Thursday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Friday'></s:text></s:i18n>",
       "<s:i18n name='forms'><s:text name='forms.Saturday'></s:text></s:i18n>"];

var str = $("#depTime").val();
str = str.replace(/-/g,"/");

/* if($("#depCityCode").val() ==null ||$("#depCityCode").val()=="" || $("#arrCityCode").val()==null || $("#arrCityCode").val()==""){
	flightTime();
} */

var weeks = new Date(str);
$("#weeks").html(d[weeks.getDay()]);
var times =  $("#Times").val();
$("#flightTime").html(times);

});
var xml_str=null;
<c:if test="${data}">
	xml_str=${data};
	$("#text").val(xml_str);
</c:if>

function resetForm(){
	
	
	$("#depCity").val("<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>");
	$("#arrCity").val("<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>");
	
	var objSelect=document.getElementById("flightNo");
    objSelect.length=0;
    var varItem = new Option("--<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>--", "");      
    objSelect.options.add(varItem);     
	$("#flightTime").html("");
	//$("#remarks").attr("checked",true);
	$("input[type='checkbox'][name='compareDataSource']").attr('checked',false);
	$("#myCompareDataSource").attr('checked',true);
	$("#depTime").val(currentDate());
	var d=["<s:i18n name='forms'><s:text name='forms.Sunday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Monday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Tuesday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Wednesday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Thursday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Friday'></s:text></s:i18n>",
	       "<s:i18n name='forms'><s:text name='forms.Saturday'></s:text></s:i18n>"];
	 var str = $("#depTime").val();
	 str = str.replace(/-/g,"/");
	 var weeks = new Date(str);
	 $("#weeks").html(d[weeks.getDay()]);
	 v1=v2=v3=null;
}

function changeEvent(){
	 var tocity = $("#depCity").val();
	 var fromcity = $("#arrCity").val();
	 /* var fromCityCode = $("#depCityCode").val();
	 var toCityCode = $("#arrCityCode").val(); */
	 if((fromcity =='' && tocity !='')||(tocity=='<s:i18n name="forms"><s:text name="forms.cnOrPingYing"></s:text></s:i18n>'&& fromcity=='<s:i18n name="forms"><s:text name="forms.cnOrPingYing"></s:text></s:i18n>')){
		 alert("<s:i18n name='forms'><s:text name='forms.chooseRoutes'></s:text></s:i18n>");
		 $("#fromCity").focus();
		 return false;
	 }else if(fromcity == tocity){
		 alert("<s:i18n name='forms'><s:text name='forms.sameCity'></s:text></s:i18n>");
		 $("#fromCity").focus();
		 return false;
	 }else if((fromcity !='' && tocity== '')||fromcity !='' && tocity== '<s:i18n name="forms"><s:text name="forms.cnOrPingYing"></s:text></s:i18n>'){
		 return false;
	 }else{
		resetRows();
		 
	 }

	
}

function submit_(){
	//check condition depCity
	$("#carrier").attr("value",$("#carriers").val()); 
	var flightNo=$("#flightNo").val();
	var depCity=$("#depCity").val();
	var arrCity=$("#arrCity").val();
	$("#carriers").val($("#carrier").val());
	if(depCity==""||depCity=='<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>'){
		alert("<s:i18n name='forms'><s:text name='forms.notFromCity'></s:text></s:i18n>");
		return ;
	}
	if(arrCity==""||arrCity=='<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>'){
		alert("<s:i18n name='forms'><s:text name='forms.notToCity'></s:text></s:i18n>");
		return ;
	}
	if(arrCity==depCity){
		alert('<s:i18n name="forms"><s:text name="forms.sameCity"></s:text></s:i18n>');
		return;
	}
	if(flightNo==""||flightNo=='undefined'||flightNo ==null){
		alert("<s:i18n name='forms'><s:text name='forms.notFlight'></s:text></s:i18n>");
		return ;
	}
	var depTime=$("#depTime").val();
	if(depTime==""||depTime==null){
		alert("<s:i18n name='forms'><s:text name='forms.notFlightDate'></s:text></s:i18n>");
		return false;
	}
	
	if($("input[type='checkbox'][name='compareDataSource']:checked").length==0){
		alert("<s:i18n name='forms'><s:text name='forms.chooseOneSource'></s:text></s:i18n>");
		return false;
	}
	_ajaxLoad();
}

function _ajaxLoad(){
	$.ajax({
        url : '<%=request.getContextPath()%>/aheadBuyTicketAction!searchView.action',
        cache : false, 
        async : true,
        type : "POST",
        data:$('#searchForm').serialize(),
        dataType:'html',
       	beforeSend:function(){
       		FDCWait.show();
       	},
       	success:function(data){
       		if(!data){
       			alert("<s:i18n name='forms'><s:text name='forms.notDatas'></s:text></s:i18n>");
       			$("#chartDiv").css('display','none');
       			return;
       		}
       		var myChart1 = new FusionCharts("<%=request.getContextPath() %>/FusionCharts/MSCombiDY2D.swf", "myChartId", "990", "380");
            myChart1.setDataXML(data);  
            
            myChart1.render("chartDiv");
            $("#chartDiv").css('display','block');
       	},
       	error:function(){
       		alert("<s:i18n name='forms'><s:text name='forms.contactAdministrator'></s:text></s:i18n>");
       	},
       	complete: function(){
       		FDCWait.hide();
       	}
    });
}

/*
 * 比较上一次选择的值
 **/
/*  var v1,v2,v3;
 var isreflush=function compareSelectValue(i,o1,o2,o3){
					  if(v1!=o1||v2!=o2||v3!=o3){
							 v1=o1;
					    	 v2=o2;
					    	 v3=o3;
							return true;
						}
					 v1=o1;
			    	 v2=o2;
			    	 v3=o3;
					 return false;
	  			} */

	  
  var i=1;
 function loadFlightNo(carriers){
	 $("#carrier").attr("value",$("#carrierss").val());
	 
 	var depCity=$("#depCity").val();
 	var arrCity=$("#arrCity").val();
 	var depCityCode=$("#depCityCode").val();
	var arrCityCode=$("#arrCityCode").val();
 	var carrier=$("#carrier").val();
 	//$("#flightTime").html("");
 	if(checkForm() && depCity!="<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>"&&arrCity!="<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>"){
 		var bool= isreflush(i,depCity,arrCity,carrier);
 		if(bool){
		    		$.ajax({
		                  url : 'commonAction!outCityFlightNo.action',
		                  data : {'depCity':depCity,'arrCity':arrCity,'fromCityCode':depCityCode,'toCityCode':arrCityCode,'carrier':carrier},
		                  type : "POST",
		                  dateType:'json',
		                  beforeSend : function(XMLHttpRequest) {// 提交之前的处理代码放在此处,可空着
		                                    
		                  },
		                  success : function(data) {
		                	  
 		                	  if(data==""||data==null){
 		                		 $("#flightNo").html("<option value=''>--请选择--</option>");
 		                		  return ;
 		                	  }
 		             
		                	  var unitys_str=data.split("#");
		                	  var objSelect=document.getElementById("flightNo");
 		                   $("#flightNo").attr("value",$("#flightNos").val());
 		               
 		                 var isExit = false;        
 		     	          for (var i = 0; i < objSelect.options.length; i++) {        
 		     	             if (objSelect.options[i].value == "") {        
 		     	      	      isExit = true;        
 		     	      	      break;        
 		     	     	     }        
 		     	    	  }   
 		     	  
 		            	  if(!isExit) {
 		           	 	  objSelect.length=1;
 		          	     }else {
		           	     objSelect.length=0;
 		            	   
 		           		    }
		                      var varItem = new Option('--<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>--', "");      
		                      objSelect.options.add(varItem);   
		                	  document.getElementById("flightNo").options[0].selected=true;
		                	  if(unitys_str.length>1){
		                		  for(var i=0;i<unitys_str.length;i++){
			                		  var s_unity=unitys_str[i];
			                		  if(s_unity!="" || s_unity!=null){
			                			  var stext=s_unity.split("=");
			                				 if('channelId'==stext[0]||stext[0]==''){
				                				  continue;
				                			  }
			                			  var opt=document.createElement("OPTION");
			                			  document.getElementById("flightNo").options.add(opt);
			                			    opt.text=stext[1];
			                			    opt.value=stext[1];
			                			    opt.grade=stext[0];
			                			    
			                		   }
			                	  }
		                	  }
		                		/*   for(var i=0;i<unitys_str.length;i++){
			                		  var s_unity=unitys_str[i];
			                		  if(s_unity!="" || s_unity!=null){
			                			  var stext=s_unity.split("=");
			                			  if('channelId'==stext[0]||stext[0]==''){
			                				  continue;
			                			  }
			                			  var opt=document.createElement("OPTION");
			                			  document.getElementById("flightNo").options.add(opt);
			                			  var stext=s_unity.split("=");
			                			 /// alert(stext+"-"+stext[1]+"-"+stext[0]);
			                			    opt.text=stext[1];
			                			    opt.value=stext[1];
			                			    opt.grade=stext[0];
			                		   }
			                	  }
		                	  }	 */
		                	  
		                  },
		                  error : function(data) {
		                	  alert('<s:i18n name="forms"><s:text name="forms.prompt"></s:text></s:i18n>', 
                      		'<s:i18n name="forms"><s:text name="forms.timeout"></s:text></s:i18n>');
		                  }
		            });
 		}
 	}
 	i++;
 }
 
 
 function checkForm(){
	 if($("#arrCityCode").val()==null || $("#arrCityCode").val()=='<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>'){
		 alert("<s:i18n name='forms'><s:text name='forms.notFromCity'></s:text></s:i18n>");
		 return false;
	 }
	 if($("#depCityCode").val() ==null || $("#depCityCode").val() == '<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>'){
		 alert("<s:i18n name='forms'><s:text name='forms.notToCity'></s:text></s:i18n>");
		 return false;
		 
	 }
	 if($("#arrCityCode").val()==$("#depCityCode").val()){
		 alert("<s:i18n name="forms"><s:text name="forms.sameCity"></s:text></s:i18n>");
		 return false;
	 }
	 
	 return true;
 }
 
 function clearFlightNo(){
	 $("#flightNo").html("<option value=''>--<s:i18n name='forms'><s:text name='forms.select'></s:text></s:i18n>--</option>");
	 $("#flightTime").html('');
 } 
 function loadweekTime(){
	 var d=["<s:i18n name='forms'><s:text name='forms.Sunday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Monday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Tuesday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Wednesday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Thursday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Friday'></s:text></s:i18n>",
	        "<s:i18n name='forms'><s:text name='forms.Saturday'></s:text></s:i18n>"];
	 var str = $("#depTime").val();
	 
	 str = str.replace(/-/g,"/");
	 var weeks = new Date(str);
	 $("#weeks").html(d[weeks.getDay()]);
	
	 
 }

 function setTimeFunction(){
	 var objS = document.getElementById("flightNo"); 
     var grade = objS.options[objS.selectedIndex].grade;
	
    
	 if($("#flightNo").val()==""||$("#flightNo").val()==null) {
		 $("#flightTime").html("");
	 }
     $("#flightTime").html(grade);
     $("#Times").attr("value",grade);
     $("#flightNos").attr("value",$("#flightNo").val());
     
 }
 
 
 
</script>
<body>
<%@ include file="/include/home/home_header.jsp" %>
<jsp:include page="/pages/system/feedback/feedback.jsp" ></jsp:include>
<div class="main main_max minhgt450">
	<div class="sideBar">
	<div class="box">
		<div class="location"><s:i18n name="forms"><s:text name="forms.position"></s:text></s:i18n>： <s:i18n name="menus"><s:text name="historicalFare"></s:text></s:i18n> &gt;  
		<s:i18n name="menus"><s:text name="advanceSales"></s:text></s:i18n></div>
	</div>
	</div>
<div class="form_table_tltle"><s:i18n name="menus"><s:text name="advanceSales"></s:text></s:i18n></div>
<form name="searchForm" id="searchForm" action="aheadBuyTicketAction!searchView.action" method="post">
<input type="hidden" id="flightNos" name="vo.flightNos"/>
<input type="hidden" id="carrier" name="vo.carrier" value="${vo.carrier }"/>
<input type="hidden" id="carriers" name="carriers"/>
<table cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table">
  <tr>
    <td class="left" width="120" align="right"><s:i18n name="forms"><s:text name="forms.airlines"></s:text></s:i18n>:</td>
    <td colspan="3">
    <select  onchange="loadFlightNo('carrierss');" style="width: 150px;" id="carrierss"  disabled="disabled" >
		<c:forEach var="item" items="${crawlCompanys}">
			<option value="${item.hbaseKey}"
			<c:if test="${item.hbaseKey==sessionScope.currentUser.sourceKey}">selected='selected' </c:if>
			>${item.name}</option>
		</c:forEach>
	</select><font color="red" >*</font>
    </td>
  </tr>
  <tr>
    <td class="left" align="right"><s:i18n name="forms"><s:text name="forms.trip"></s:text></s:i18n>：</td>
    <td width="300"> 
    	<c:if test="${language=='en_US'}">
		   	<jsp:include page="../../inc/flightSelect_en_Us.jsp"></jsp:include>
		 </c:if>
		 <c:if test="${language=='zh_CN' or language=='other'}">
				<jsp:include page="../../inc/flightSelect.jsp"></jsp:include>
		</c:if>
	   <%--  <input type="text" name="vo.fromCityName" style="width:100px" id="depCity"  onclick="clearFlightNo()" value="${vo.fromCity }" readonly="readonly"> 
	    <span>到</span>
	   <input type="text" name="vo.toCityName" style="width:100px" id="arrCity" onclick="clearFlightNo()" value="${vo.toCity }" readonly="readonly"><font color="red" >*</font> --%>
   </td>
    <td class="left" width="120" align="right"><s:i18n name="forms"><s:text name="forms.flight"></s:text></s:i18n>: </td> 
    <td>
     <select name="vo.flightNo" id="flightNo" onclick="loadFlightNo('carrierss');" onchange="setTimeFunction()">
      <c:if test="${not empty vo.flightNo }"> 
      <option value="${vo.flightNo }">${vo.flightNo }</option>
      </c:if>
       <c:if test="${empty vo.flightNo }">
	    <option value="" >--<s:i18n name="forms"><s:text name="forms.select"></s:text></s:i18n>--</option></c:if>
	    </select><font color="red" id='_fontInfo'>*</font>
	  
      <span id="flightTime"></span>
     <input id="Times" name= "vo.flightTimes"  type="hidden"  value="${vo.flightTimes }" >
   </td> 
  </tr>
  <tr>
  <td class="left" align="right"><s:i18n name="forms"><s:text name="forms.flightDate"></s:text></s:i18n>：</td>
  
  <td>  	  

  <input name="vo.depTime" type="text" id="depTime" style="width:100px" value="${vo.depTime}" onClick="WdatePicker({onpicked:loadweekTime,maxDate:'%y-%M-{%d+15}',lang:'<s:text name='forms.locale'/>'})" readonly="readonly"> &nbsp;<font color="red" >*</font>

   <span ></span><span id="weeks"></span> </td>
  <td class="left" align="right"><s:i18n name="forms"><s:text name="forms.dataSources"></s:text></s:i18n>：</td>
  <td>

	  	<!-- 
		  <input type="radio" name="vo.remark" id= "remarks" value="1" checked="checked">仅官网&nbsp;
		   <input type="radio" name="vo.remark" <c:if test="${vo.remark==0 }">checked="checked" </c:if> value="0">全渠道
	    -->
	    <table>
	    	<tr>
	    		<td style='padding:5px 5px 5px 0px;border-bottom:0px;'>
	    			<input type='checkbox' id="myCompareDataSource" name='compareDataSource' value='${myCompanyOrChannel}' checked='checked' />&nbsp;<s:i18n name="forms"><s:text name="forms.B2C"></s:text></s:i18n>
	    		</td>
	    	</tr>
	    	<tr>
	    		<c:forEach var="item" items="${crawlChannels}">
				<td  style='padding:5px 5px 5px 0px;border-bottom:0px;'>
					<input type="checkbox" value="${item.hbaseKey}" name="compareDataSource" />&nbsp;${item.name }&nbsp;&nbsp;&nbsp;
				</td>
				</c:forEach>
	    	</tr>
	    </table>

  </td>
  </tr>
  <tr>
 <td colspan="4" style="text-align:center;height:35px;">
 <input type="button"  onclick="submit_()" value="" class="<s:i18n name='forms'><s:text name='forms.btn01'></s:text></s:i18n>"/>
 <input type="button" onclick="resetForm()"  value="" class="<s:i18n name='forms'><s:text name='forms.btn02'></s:text></s:i18n>"/>
 </td>
  </tr>
</table>
</form>
<br/>


<div id="chartDiv" align="center" style="padding-bottom: 1px; width: 100%; height: 420;"></div>

</div>

 <br></br>

 
 <br ><br><br ><br><br><br><br><br><br><br><br>
<%@ include file="/include/home/home_footer.jsp" %> 
</body>
</html>

	